﻿using Pb;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class MahjongCraetRoom : MonoBehaviour
{

    //public GameObject CloseBtn;
    public GameObject CreatRoomBtn;
    public GameObject ReplaceCreateRoomBtn;

    public List<GameObject> BaseScoreChooseStatus;
    public List<GameObject> BaseScoreChooseBtn;
    private int baseScore;

    public List<GameObject> GameRoundChooseStatus;
    public List<GameObject> GameRoundChooseBtn;
    private int TotalRound;

    public List<GameObject> HongChooseStatus;
    public List<GameObject> HongChooseBtn;
    private bool isHaveLaiz;

    public List<GameObject> JiangChooseStatus;
    public List<GameObject> JiangChooseBtn;
    private bool is258Jiang;

    public List<GameObject> FishChooseStatus;
    public List<GameObject> FishChooseBtn;
    private int FishCount;

    private void Awake()
    {
        //UIEventListener.Get(CloseBtn).onClick = ButtonClick;
        UIEventListener.Get(CreatRoomBtn).onClick = ButtonClick;
        UIEventListener.Get(ReplaceCreateRoomBtn).onClick = ButtonClick;
        for (int i = 0; i < BaseScoreChooseBtn.Count; i++)
        {
            UIEventListener.Get(BaseScoreChooseBtn[i]).onClick = ButtonClick;
        }
        for (int i = 0; i < GameRoundChooseBtn.Count; i++)
        {
            UIEventListener.Get(GameRoundChooseBtn[i]).onClick = ButtonClick;
        }
        for (int i = 0; i < HongChooseBtn.Count; i++)
        {
            UIEventListener.Get(HongChooseBtn[i]).onClick = ButtonClick;
        }
        for (int i = 0; i < JiangChooseBtn.Count; i++)
        {
            UIEventListener.Get(JiangChooseBtn[i]).onClick = ButtonClick;
        }
        for (int i = 0; i < FishChooseBtn.Count; i++)
        {
            UIEventListener.Get(FishChooseBtn[i]).onClick = ButtonClick;
        }
        baseScore = 10000;
        TotalRound = 4;
        isHaveLaiz = true;
        is258Jiang = true;
        FishCount = 2;
    }
    void ButtonClick(GameObject button)
    {
        if (button.name == "1w")
        {
            BaseScoreChooseStatus[0].SetActive(true);
            BaseScoreChooseStatus[1].SetActive(false);
            BaseScoreChooseStatus[2].SetActive(false);
            baseScore = 10000;
        }
        else if (button.name == "5w")
        {
            BaseScoreChooseStatus[0].SetActive(false);
            BaseScoreChooseStatus[1].SetActive(true);
            BaseScoreChooseStatus[2].SetActive(false);
            baseScore = 50000;
        }
        else if (button.name == "10w")
        {
            BaseScoreChooseStatus[0].SetActive(false);
            BaseScoreChooseStatus[1].SetActive(false);
            BaseScoreChooseStatus[2].SetActive(true);
            baseScore = 100000;
        }

        else if (button.name == "4ju")
        {
            GameRoundChooseStatus[0].SetActive(true);
            GameRoundChooseStatus[1].SetActive(false);
            GameRoundChooseStatus[2].SetActive(false);
            TotalRound = 4;
        }
        else if (button.name == "8ju")
        {
            GameRoundChooseStatus[0].SetActive(false);
            GameRoundChooseStatus[1].SetActive(true);
            GameRoundChooseStatus[2].SetActive(false);
            TotalRound = 8;
        }
        else if (button.name == "16ju")
        {
            GameRoundChooseStatus[0].SetActive(false);
            GameRoundChooseStatus[1].SetActive(false);
            GameRoundChooseStatus[2].SetActive(true);
            TotalRound = 16;
        }

        else if (button.name == "honglai")
        {
            HongChooseStatus[0].SetActive(true);
            HongChooseStatus[1].SetActive(false);
            isHaveLaiz = true;
        }
        else if (button.name == "wulai")
        {
            HongChooseStatus[0].SetActive(false);
            HongChooseStatus[1].SetActive(true);
            isHaveLaiz = false;
        }

        else if (button.name == "258jiang")
        {
            JiangChooseStatus[0].SetActive(true);
            JiangChooseStatus[1].SetActive(false);
            is258Jiang = true;
           
        }
        else if (button.name == "luanjiang")
        {
            JiangChooseStatus[0].SetActive(false);
            JiangChooseStatus[1].SetActive(true);
            is258Jiang = false;
        }

        else if (button.name == "2fish")
        {
            FishChooseStatus[0].SetActive(true);
            FishChooseStatus[1].SetActive(false);
            FishChooseStatus[2].SetActive(false);
            FishCount = 2;
        }
        else if (button.name == "5fish")
        {
            FishChooseStatus[0].SetActive(false);
            FishChooseStatus[1].SetActive(true);
            FishChooseStatus[2].SetActive(false);
            FishCount = 5;
        }
        else if (button.name == "8fish")
        {
            FishChooseStatus[0].SetActive(false);
            FishChooseStatus[1].SetActive(false);
            FishChooseStatus[2].SetActive(true);
            FishCount = 8;
        }
        else if (button.name == "CreatRoomBtn")
        {
            MahjongOpenRoomRequest MR = new Pb.MahjongOpenRoomRequest { TotalRound = TotalRound, BaseScore = baseScore, Is258Jiang = is258Jiang, IsAgentRoom = false, IsCardRoom = false,IsLaiziRoom=isHaveLaiz };
            SocketManager socketManager = SocketManager.Instance;
            socketManager.SendProtobuf1(MR, MsgId.MahjongOpenRoomRequest);
        }
        else if (button.name == "ReplaceCreateRoomBtn")
        {
            MahjongOpenRoomRequest MR = new Pb.MahjongOpenRoomRequest { TotalRound = TotalRound, BaseScore = baseScore, Is258Jiang = is258Jiang, IsAgentRoom = true, IsCardRoom = false, IsLaiziRoom = isHaveLaiz };
            SocketManager socketManager = SocketManager.Instance;
            socketManager.SendProtobuf1(MR, MsgId.MahjongOpenRoomRequest);
        }
    }
}
